package binaryTree;

import utils.binaryTreeUtil.TreeNode;

public class isSymmetric {
    public boolean isSymmetric(TreeNode root) {
        return symmetric(root.left,root.right);
    }
    public boolean symmetric(TreeNode lNode,TreeNode rNode){
        if(lNode==null&&rNode==null){
            return true;
        }else if(lNode==null&&rNode!=null){
            return false;
        }else if(lNode!=null&&rNode==null){
            return false;
        }else{
            if (lNode.val==rNode.val) {
                return symmetric(lNode.left, rNode.right)&&symmetric(lNode.right, rNode.left);
            }else{
                return false;
            }
            
        }
    }

    public static void main(String[] args) {
        
    }
}
